﻿using System;
using System.Collections.Generic;
using RBOSS.Business.Presenters;
using RBOSS.Business.Products;
using RBOSS.Business.Views;
using RBOSS.WebUI.Models;

namespace RBOSS.WebUI
{
    public partial class Default : MasterSite,IProductView
    {
        public List<ProductItem> Products { get; set; }
        private readonly ProductPresenter _productPresenter;

        public Default()
        {
            _productPresenter = new ProductPresenter(this);
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            var search = Request.QueryString["s"];
            var category = Request.QueryString["c"];
            if (category != null)
            {
                Products = _productPresenter.GetProductByCategory(category);
            }
            else if (search != null)
            {
                Products = _productPresenter.SearchProduct(search);
            }
            else
            {
                Products = _productPresenter.GetProducts();
            }
        }


        public int ProductId
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }
    }
}